<template>
  <div class="login">
    <van-nav-bar title="注册/登录" left-arrow @click-left="onClickLeft" />
    
    
    <van-form @submit="onSubmit" ref="regform">
  <van-field
    v-model="username"
    name=""
    label=""
    left-icon="phone-o"
    placeholder="请输入手机号"
    :rules="[{ required: true, message: '请输入手机号' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name=""
    label=""
    left-icon="eye-o"
    placeholder="请输入密码"
    
  />
  <van-field
    v-model="sms"
    type="password"
    name=""
    label=""
    left-icon="eye-o"
    placeholder="请输入验证码"
    >
    </van-field>
 <van-button type="primary" size="mini"  @click="getSms()">获取验证码</van-button>
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit" @click="getData">提交</van-button>
  </div>
  
</van-form>
  </div>
  
</template>

<script>
export default {
  data() {
    return {
      username: "",
      password: "",
      sms: "",
      // btn:false,
    };
  },

  mounted() {
     this.getData()
  },
  methods: {
    onClickLeft() {
            this.$router.back()
        },
    onSubmit(values) {
      console.log("submit", values);
    },
    getData() {
      this.$http
        .post("/user/reg", {
          username: this.username,
          password: this.password,
          vercode: this.sms,
        })
        .then((res) => {
          console.log(res);
        });
    },
    getSms() {
     
 

      this.$http
        .post("/user/sendSms", { mobile: this.username, type: "register" })
        .then((res) => {
          console.log(res);
        });
       
    },
  },
};
</script>
</script>

<style lang="less" scoped>


.van-button--mini{
    display: flex;
    top: -35px;
    right: -270px;
    background-color: rgb(237, 230, 230);
    border: none;
    border-radius: 30px;
}
.van-button__text{
    color: #323233;
}
.van-button--round{
    background: #07c160;
    border-radius: 0;
    border: none;
}
</style>